import { createStore } from 'vuex'

export default createStore({
    state: {
        count : 1,
        menuLoaded : [],
        dynamicRouter : {

        }
    },
    mutations: {
        setDynamicRouter(state,payload){
            state.dynamicRouter[payload.to] = payload.dynamicRouter;
        }
    },
    actions: {
    },
    modules: {
    },
    getters: {
        count: state => {
            return  state.count;
        },
        menuLoaded : (state, getters) => {
            if(state.menuLoaded.indexOf(getters) > -1){
                return true;
            }else {
                state.menuLoaded.push(getters);
                return false;
            }
        },
        getDynamicRouter : state=> (name) => {
            return state.dynamicRouter[name];
        },
        isDynamicRouter : state=> (name) => {
            console.log(1)
            return state.dynamicRouter[name] !== undefined;
        }
    }
})
